import tkinter
import pyperclip

URL = "https://systemlight.tpddns.cn:8003/"


def transform():
    path = result.get()
    r_path = URL + path.replace("\\", "/").lstrip("/")
    pyperclip.copy(r_path)
    output_text.insert("end", r_path)


root = tkinter.Tk()

screen_w = root.winfo_screenwidth()
screen_h = root.winfo_screenheight()
window_w = 800
window_h = 800
position_x = int((screen_w / 2) - (window_w / 2))
position_y = int((screen_h / 2) - (window_h / 2))

root.geometry("{}x{}+{}+{}".format(window_w, window_h, position_x, position_y))
root.resizable(width=False, height=False)

title = tkinter.Label(text="路径转换工具", font="微软雅黑 20 bold")
title.pack(anchor=tkinter.N)

top_form = tkinter.Frame()
top_form.pack(anchor=tkinter.N, pady=(20, 0))

text_box_label = tkinter.Label(top_form, text="输入路径")
text_box_label.pack(side=tkinter.LEFT, padx=(0, 20))

result = tkinter.StringVar(master=root)
text_box = tkinter.Entry(top_form, textvariable=result, width=50, bg="#F0F0F0")
text_box.pack(side=tkinter.LEFT)

ok_button = tkinter.Button(text="转换并复制", command=transform)
ok_button.pack(anchor=tkinter.N, pady=20, ipadx=100, ipady=20)

output_text = tkinter.Text()
output_text.pack(anchor=tkinter.N)

root.mainloop()
